package com.destin.basic.controller.system;

import com.destin.basic.dto.UserModifyDTO;
import com.destin.basic.eneity.User;
import com.destin.basic.security.LoginUserInfo;
import com.destin.basic.service.admin.AdminService;
import com.destin.basic.util.CommonPage;
import com.destin.basic.util.JsonResponse;
import com.destin.basic.util.UserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author: Destin
 * @date: 2022-02-23
 */
@Api("用户接口")
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    AdminService adminService;

    @GetMapping("/list")
    @ApiOperation("查询用户列表")
    public JsonResponse<CommonPage> list() {
        return JsonResponse.ok(CommonPage.restPage(adminService.selectList()));
    }

    @PostMapping("/add")
    @ApiOperation("添加用户")
    public JsonResponse<Boolean> add(@Valid @RequestBody UserModifyDTO userModifyDTO) {
        return JsonResponse.ok(adminService.add(userModifyDTO));
    }
}
